package com.parroquia.sacramento.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.annotations.Validations;
import com.opensymphony.xwork2.validator.annotations.ValidatorType;
import com.parroquia.sacramento.model.Bautismo;

@Action(value="register-bautismo", 
results={
	@Result(name="exito", location="/message.jsp"),
	@Result(name="error", location="/bautismo.jsp"),
	@Result(name="input", location="/bautismo.jsp")
	}
)
public class Bautismo_Action extends ActionSupport{
	
	private static final long serialVersionUID = 1L;
	
	private Bautismo bautismo;
	private String message;
	
	@Validations(
		       requiredStrings =
		        	{  @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "nombre", key = "bautismo.nombre.required"),
		    		   @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "apePat", key = "bautismo.apePat.required"),
		    		   @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "apeMat", key = "bautismo.apeMat.required"),
		    		   @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "dni", key = "bautismo.dni.required"),
		        	},
		  
		    	stringLengthFields =
       	{
		    		   @StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim = true, minLength="8" , maxLength = "8", fieldName = "dni", key = "bautismo.dni.length")
       	}
	)
	
	public String execute(){
		String result="exito";
		
		return result;
	}
	
	public Bautismo getBautismo() {
		return bautismo;
	}
	public void setBautismo(Bautismo bautismo) {
		this.bautismo = bautismo;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	
	
	
	
	
}
